function InserSort (arr) {
  let len = arr.length
  if (len<0) return
  let perIndex, current;
  for (let i  = 1; i< len; i++) {
    perIndex = i -1;
    current = arr[i]
    while (perIndex >= 0 && current < arr[perIndex]) {
       arr[perIndex + 1] = arr[perIndex]
       perIndex --;
    }
    arr[perIndex + 1] = current;
  }
  return arr;
}
let  arr = [3,5,7,1];
InserSort(arr);
console.log(InserSort(arr))
